package org.example.controller;

import com.alibaba.druid.filter.config.ConfigTools;
import org.example.entity.EmailRecord;
import org.example.mapper.EmailRecordMapper;
import org.example.service.EmailRecordService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @description:
 * @author: yh
 * @date: 2022/12/18
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Resource
    private EmailRecordService emailRecordService;

    @GetMapping(value = "/get")
    public String get(){
        EmailRecord emailRecord = emailRecordService.getById(28);
        if(null == emailRecord){
            return "id 不存在";
        }
        return emailRecord.toString();
    }

    public static void main(String[] args) throws Exception {

        // 公钥
        String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJIavWOrjPYNSTkSeUmiCSbAvPHjv2LI9Ow3rTrg9gHuYGpiccvLpYLZhvTNW26XNOSNP+fsKFMnBYXcB/IVa0UCAwEAAQ==";
        // 密文
        String password = "PUz+7JCeI1mvHG3q4FBtOkjBp9WSNaptqQtpAEhHKSjHTbcN/4dALkNnY9lmcdTBekepmidkZ/VwNtUnfZ0k1Q==";
        String decrypt = ConfigTools.decrypt(publicKey, password);
        System.out.println(decrypt);
//        // 需要加密的明文密码
//        String password = "1qazzaq1";
//        // 调用 druid 生成私钥、公钥、密文
//        ConfigTools.main(new String[]{password});
    }

    public static void main2(String[] args) throws Exception {
        // 公钥
        String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJIavWOrjPYNSTkSeUmiCSbAvPHjv2LI9Ow3rTrg9gHuYGpiccvLpYLZhvTNW26XNOSNP+fsKFMnBYXcB/IVa0UCAwEAAQ==";
        // 密文
        String password = "PUz+7JCeI1mvHG3q4FBtOkjBp9WSNaptqQtpAEhHKSjHTbcN/4dALkNnY9lmcdTBekepmidkZ/VwNtUnfZ0k1Q==";
        String decrypt = ConfigTools.decrypt(publicKey, password);
        System.out.println(decrypt);
    }
}
